package org.restly.representations;

import org.restly.*;

import java.io.IOException;

/**
 * Oct 29, 2008, 11:50:36 AM
 *
 * @author <a href="http://restly.org/">Erik Beeson</a>
 */
public class SeeOtherRepresentation implements Representation {
	private final String url;

	public SeeOtherRepresentation(String url) {
		this.url = url;
	}

	public void represent(org.restly.servlet.RestlyContext context, org.restly.servlet.RestlyHttpServletRequest request, org.restly.servlet.RestlyHttpServletResponse response) throws IOException {
		response.setStatus(HttpStatus.SEE_OTHER);
		response.setHeader("Location", url);
		response.getWriter().println("<a href=\"" + url + "\">" + url + "</a>");
	}
}
